function sandbox = fsb_import_spm(SPM,sandbox)

% FSB - DEV: Import SPM experiment structure into sandbox struct
%
% EXAMPLE:
% sandbox = fsb_import_spm(SPM)
%
% INPUT:
% SPM:      SPM struct
% sandbox:  sandbox experiment struct
%
% OUTPUT:
% sandbox:  sandbox experiment struct
% 
% CALLED BY:
% fsb_load_files.m
%
% NOTES:
% In development, needs to be completed
% Imports data from various SPM format structs
%
% Copyright 2010 MPI for Biological Cybernetics
% Author: Steffen Stoewer
% License:GNU GPL, no express or implied warranties
% 
%$Revision 1.0
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
spmid = SPM.SPMid(1:5);
disp(['SPM version is ' spmid]);

switch spmid
    case spm99
        sandbox.TR = SPM.xsDes.Interscan_interval;
        % sandbox.hdr =
        sandbox.volmat.evt_onsets = SPM.Sess.U.ons;
        sandbox.volmat.evt_names = SPM.Sess.U.name;
        sandbox.volmat.evt_dur = SPM.Sess.U.dur;
        sandbox.hemodynamics = SPM.xX.xKXx.X; % I cannot yet tell which is which


    case spm2
        % Not yet implemented


    case spm5

        sandbox.TR = SPM.xsDes.Interscan_interval; % This will also include a string indicating the unit
        sandbox.TR = SPM.xX.K.RT;
        sandbox.hdr = SPM.xVol.VRpv.private.hdr;
        sandbox.volmat.evt_onsets = SPM.Sess{1,1}.ons;
        sandbox.volmat.evt_names = SPM.Sess{1,1}.name;
        sandbox.volmat.evt_dur = SPM.Sess.U.dur;
        sandbox.hemodynamics = SPM.xX.xKXs.u;
        sandbox.hemodynamics = SPM.xX.xKXx.X; % I cannot yet tell which is which
end

end
